/**
 * Created by Administrator on 2018/2/5.
 */
myApp_.onPageInit('seller_examine', function () {
    SELLER_EXAMINE.do_get();
});


SELLER_EXAMINE = {};
SELLER_EXAMINE.__INIT__ = function () {
    mainView.router.load({
        url: "src/seller/examine/examine.html",
    });
}
SELLER_EXAMINE.coll = {
    head_img: '',
    seller_name: '',
    seller_address: '',
    true_name: '',
    telephone: ''
}
// 页面上取值
SELLER_EXAMINE.view_to_model = function () {
    SELLER_EXAMINE.coll = {
        head_img: $("input[name='head_img']").val(),
        seller_name: $("input[name='seller_name']").val(),
        seller_address: $("input[name='seller_address']").val(),
        true_name: $("input[name='true_name']").val(),
        telephone: $("input[name='telephone']").val()
    }

}

SELLER_EXAMINE.model_to_view = function (obj) {
    $("input[name='head_img']").val(obj.head_img)
    $("input[name='seller_name']").val(obj.seller_name)
    $("input[name='seller_address']").val(obj.seller_address)
    $("input[name='true_name']").val(obj.true_name)
    $("input[name='telephone']").val(obj.telephone)
    SELLER_EXAMINE.show_head_img();
}


SELLER_EXAMINE.do_get = function () {
    request_(
        url_('addons/execute/seller-App-seller_info'), {},
        function (d) {
            var context = d.data;
            SELLER_EXAMINE.model_to_view(context);
        }
    );
}

SELLER_EXAMINE.do_request = function () {
    SELLER_EXAMINE.view_to_model();
    var param = SELLER_EXAMINE.coll;
    if (
        !param.head_img || !param.seller_name || !param.seller_address || !param.telephone || !param.true_name
    ) {
        my_tips_("请补全信息后提交");
        return;
    }
    request_(
        url_('addons/execute/seller-App-seller_examine'),
        param,
        function (d) {
            if (d.code == 0) {
                my_tips_("提交成功，请等待后台人员审核", function () {
                    go_("my_center");
                })
            } else {
                my_tips_(d.msg)
            }
        }
    );

}
SELLER_EXAMINE.show_head_img=function(){
    var img = $("input[name='head_img']").val();
    $("#head_img").attr("src",img_url+'/'+img);
}
SELLER_EXAMINE.camera = function () {
    use("tool/camera");
    $.camera({
        callback: function (param) {
            var data = param.response;
            if (data.code == 0) {
                var img = data.data;
                $("input[name='head_img']").val(img)
                SELLER_EXAMINE.show_head_img();
            }
        }
    });
}